#!/bin/bash
if [ -d deploy ];
then
   echo "Removing deploy";
   rm -r deploy;
fi

mkdir deploy
cp -r css/ scripts/ pages/ index.html deploy

cd deploy
find -iname *svn* | xargs rm -rf

cd ../smartsprites/
sh smartsprites.sh --root-dir-path ../deploy/css --sprite-png-ie6
cd ../deploy/css/

echo "Adapting sprite css"
rm structure.css structure_ie6.css corners.css corners_ie6.css
mv structure-sprite.css structure.css
mv structure_ie6-sprite.css structure_ie6.css
mv corners-sprite.css corners.css
mv corners_ie6-sprite.css corners_ie6.css
cd images/
rm -r menu/ green/ sky/ white/ title/

echo "enabling jsapi"
cd ../../../
sh compress.sh

perl -pi.bak -e 's/<!-- CommentOnDeployStart -->/<!-- /g' deploy/index.html
perl -pi.bak -e 's/<!-- CommentOnDeployEnd -->/ -->/g' deploy/index.html

perl -pi.bak -e 's/<!-- UnCommentOnDeployStart//g' deploy/index.html
perl -pi.bak -e 's/UnCommentOnDeployEnd -->//g' deploy/index.html

rm deploy/index.html.bak
